package Servlet.User;

import Dao.FindLunBoDao;
import Table.Lunbo;
import com.alibaba.fastjson.JSON;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

@WebServlet("/userLunBoServlet")
public class UserLunBoServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArrayList<Lunbo> list = FindLunBoDao.Find();
        PrintWriter out = resp.getWriter();
        resp.setContentType("application/json;charset=utf-8");
        String s = JSON.toJSONString(list);
        out.print(s);
        System.out.println(s);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
